/*******************************************************************************
* Copyright 2017 CLNST CO., LTD.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/

#ifndef ___UART_CTRL_H__
#define ___UART_CTRL_H__

#include <stdio.h>
#include <fcntl.h>
#include <string.h>
#include <stdlib.h>
#include <sys/times.h>
#include <sys/types.h>
#include <termios.h>
#include <unistd.h>
#include <sys/ioctl.h>

#define JOINT_MAX   6
#define PI                        3.1415926

/**
  * @brief  机械臂发送数据转换
  * @param  输入弧度
  * @retval 变换后的角度
  */
double rocr6_tf_tdata(double dt);

/**
  * @brief  机械臂接收数据转换
  * @param  输入角度
  * @retval 变换后的弧度
  */
 double rocr6_tf_rdata(double dt);

/**
  * @brief  机械臂发送角度数据
  * @param  命令，参数，角度值
  * @retval 实际发送的数据
  */
int rocr6_txSig(unsigned short cmd, unsigned short index, const double dt[6]);

/**
  * @brief  机械臂接收角度数据
  * @param  接收到的角度
  * @retval 机械臂运行状态
  */
int rocr6_rxSig(double dt[6]);

/**
  * @brief  机械臂抱闸设置
  * @param  无
  * @retval 无
  */
void rocr6_brake(unsigned char flag);

/**
  * @brief  机械臂广播设置
  * @param  无
  * @retval 无
  */
void rocr6_broadcast(unsigned char flag);

/**
  * @brief  机械臂回HOME位置
  * @param  无
  * @retval 无
  */
void rocr6_home_config(void);

/**
  * @brief  机械臂初始化
  * @param  设备名称
  * @retval 初始化结果
  */
int rocr6_init(const char * dev);

/**
  * @brief 机械臂反初始化
  * @param  无
  * @retval 无
  */
void rocr6_deinit(void);

#endif // ___UART_CTRL_H__
